#include "lz4_algorithm.h"

std::string lz4_compress(std::string &input)
{
    int osz = LZ4_compressBound(input.size());
    char *pchCompressed = new char[osz];
    LZ4_compress_default(input.c_str(), pchCompressed, input.size(), osz);

    std::string ret = pchCompressed;
    delete[] pchCompressed;
    pchCompressed = 0;

    return ret;
}

std::string lz4_decompress(std::string &input)
{
    // int size = input.size() * 2 + 8;
    int size = 4096;
    
    char *pchDeCompressed = new char[size]; // (nCompressedInputSize *2) +8
    LZ4_decompress_safe(input.c_str(), pchDeCompressed, size, size);
    
    std::string ret = pchDeCompressed;
    delete[] pchDeCompressed;
    pchDeCompressed = 0;

    return ret;
}